/* This program displays the Character Speed WPM on line 1 and Character Clock Timing on line 2 of a 16 x 2 LCD display based on a HD44780 display controller (Parallel Interface). LCD fed from the MEGA End pins. / ddf - WA7RSO - 07/01/2013 - Modified 08/22/2013 / Clock Rate in Hz is determined by WPM/1.2 or Timing Interval (in milliseconds) by 1.2/WPM Checks for Dit Paddle or Dah Paddle inputs, to execute Dit/Dah Timing. Modes are: PARIS Calibration Test Basic Self-Completing Dits & Dahs, Iambic, Bug-Simulation, Squeeze-Key, Simple Key Memory Send_DIT() and Send_DAH() have been shortened to DIT() and DAH() */ #include // alert compiler to include the lcd library // initialize the library with the numbers of the Arduino pins used byte LCDGround1=54; // Pin 1 on the LCD byte LCD5V =52; // Pin 2 on the LCD byte Contrast =50; // Pin 3 on the LCD byte ReadStrobe=48; // Pin 4 on the LCD byte ReadWrite=46; // Pin 5 on the LCD byte Enable=44; // Pin 6 on the LCD byte DB0=42; // Pin 7 on the LCD byte DB1=40; // Pin 8 on the LCD byte DB2=38; // Pin 9 on the LCD byte DB3=36; // Pin 10 on the LCD byte DB4=34; // Pin 11 on the LCD byte DB5=32; // Pin 12 on the LCD byte DB6=30; // Pin 13 on the LCD byte DB7=28; // Pin 14 on the LCD byte Backlight=26; // Pin 15 on the LCD byte LCDGround2=24; // Pin 16 on the LCD // Using "Equated" values (lcd(48,44,34,32,30,28)) LiquidCrystal lcd(ReadStrobe,Enable,DB4,DB5,DB6,DB7); //i.e. LiquidCrystal lcd(48,44,34,32,30,28); // int WPM = 15; // All calculations and 2-line display are from this setting float Speed = WPM/1.2; // Speed in Clocks per Second (Hz) float Clock = (1000*(1.2/WPM)); // Interval in milliseconds // Physical Pin Assignments byte TP=8; // Dit Paddle Pin byte HP=9; // Dah Paddle Pin //pinMode (TP, INPUT_PULLUP); // Turn on the 20K pullup resistor //pinMode (HP, INPUT_PULLUP); // Internal Logic for Modes and Controls int TR=0; // Wait for a "Request" int HR=0; // Wait for a "Request" byte TE=1; // Initialize as "Enabled" byte HE=1; // Initialize as "Enabled" // Resulting Outputs int TA=11; // Dit Active Pin Assignment int HA=12; // Dah Active Pin Assignment int Xmit=13; // Xmit Active Pin Assignment, by either TA or HA Action // "Mode" Definitions: // Mode-0 PARIS Test Demo Mode // Mode-1 Standard Self-Completing // Mode-2 IAMBIC // Mode-3 BUG // Mode-4 Squeeze // Mode-5 Straight Key // String Mode_Text; //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = int Mode=0; // Self-Completing, with "Squeeze Hold" //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = int dits,dahs,count; int Normal_Flag, Iambic_Flag, Bug_Flag, Squeeze_Flag; String CharSpeed = ("Char Speed "); // i.e. "Words per Minute" String CharClock = (" ms Hz Clk"); //===================================================================== void setup() //required function { Serial.begin(9600); // For the "Monitor Feedback" // === Define the pin assignments === pinMode(LCD5V,OUTPUT); // Set the +5V Source High pinMode(Contrast,OUTPUT); // Set High pinMode(ReadWrite,OUTPUT); // Set Low pinMode(Backlight,OUTPUT); // Set High pinMode(LCDGround2,OUTPUT); // Set Low // pinMode(Xmit,OUTPUT); // Clock Rate for "Dit-On" & "Dit-Off" pinMode(TA,OUTPUT); pinMode(HA,OUTPUT); pinMode(8,INPUT); // Pin #8 for Input "TP" pinMode(9,INPUT); // Pin #9 for Input "HP" pinMode(10,OUTPUT); // Initial LCD Display of Character WPM and correct timing required lcd.begin(16,2); //let the program know the size of the display to be handled // digitalWrite(LCD5V,HIGH); // Turn on the +5V Sourc digitalWrite(Contrast,LOW); // Set the Contrast for normal //(Manual ground, or a diode, appears to be necessary on the Blue 2x16 LCDs, for LOW on R/W) digitalWrite(ReadWrite,LOW); // Eanable Writing to the LCD digitalWrite(Backlight,HIGH); // Turn ON the Backlight digitalWrite(LCDGround2,LOW); // Establish a Low to simulate Ground on pin 16 // printspeed(); // calls the function to print the WPM message printspecs(); // calls the function to print the "Timing Parametes" delay(3000); // Show_Mode(); /* if(Mode==5) { Straight_Key(); } */ // printclock(); // calls the function to print the first 16 characters of the message } //======================= Now, Run the Respective "Mode" required ============================================== void loop() { if(Mode==0) { PARIS_Calibration(); } if(Mode==1) { Self_Completing(); } if(Mode==2) { Iambic(); } if(Mode==3) { Bug_Emulation(); } if(Mode==4) { Squeeze(); } } //======================= Mode-0 "PARIS" Calibration ============================================== void PARIS_Calibration() // Dummy Loop, or "PARIS" Calibration { loop; { count=1; for(int i=0; i